# Python 2.6.4
# Project Euler, Problem 68
# Copyright 2010 Talha Zaman

o1 = 10
for i1 in range(1,10):
    for i2 in range(1,10):
        if i2==i1: continue
        s = o1+i1+i2
        for o2 in range(1,10):
            if o2 in [i1, i2]: continue
            i3 = s-o2-i2
            if not 0<i3<10 or i3 in [o2, i1, i2]: continue
            for o3 in range(1, 10):
                if o3 in [o2, i1, i2, i3]: continue
                i4 = s-o3-i3
                if not 0<i4<10 or i4 in [o2, o3, i1, i2, i3]: continue
                for o4 in range(1, 10):
                    if o4 in [o2, o3, i1, i2, i3, i4]: continue
                    i5 = s-o4-i4
                    if not 0<i5<10 or i5 in [o2, o3, o4, i1, i2, i3, i4]: continue
                    o5 = s-i5-i1
                    if not 0<o5<10 or o5 in [o2, o3, o4, i1, i2, i3, i4, i5]: continue
                    print o1, i1, i2, ";", o2, i2, i3, ";", o3, i3, i4, ";", \
                          o4, i4, i5, ";", o5, i5, i1
